package com.zdlyh.service.impl;

import com.zdlyh.service.MailboxService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author liuYuhui
 * @Date 2023/5/8 15:51
 */
@Service
public class MailboxServiceImpl implements MailboxService {
    @Resource
    private JavaMailSender javaMailSender;

    @Override
    public void sendMsg(String to, String subject, String context,String from) {
        SimpleMailMessage mailMessage = new SimpleMailMessage();

        mailMessage.setFrom(from);
        mailMessage.setTo(to);
        mailMessage.setSubject(subject);
        mailMessage.setText(context);

        // 真正的发送邮件操作，从 from到 to
        javaMailSender.send(mailMessage);
    }
}
